import vue from '@vitejs/plugin-vue';
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
import { viteMockServe } from 'vite-plugin-mock';
import IconsResolver from 'unplugin-icons/resolver';
import Icons from 'unplugin-icons/vite';
import * as process from 'node:process';
import * as path from 'node:path';
import { FileSystemIconLoader } from 'unplugin-icons/loaders';
import vueJsx from '@vitejs/plugin-vue-jsx';

export default [
    vue(),
    vueJsx(),
    AutoImport({
        dirs: [],
        dts: 'types/auto-imports.d.ts',
        imports: ['vue'],
        resolvers: [
            ElementPlusResolver({
                importStyle: false
            })
        ]
    }),
    Components({
        dirs: [],
        dts: 'types/components.d.ts',
        resolvers: [
            ElementPlusResolver({
                importStyle: false
            }),
            IconsResolver({
                enabledCollections: ['ep'],
                customCollections: ['custom']
            })
        ]
    }),
    Icons({
        compiler: 'vue3',
        defaultStyle: 'vertical-align: -0.15em;fill: currentcolor;',
        customCollections: {
            custom: FileSystemIconLoader(path.join(process.cwd(), './src/assets/icons'))
        },
        iconCustomizer(_collection, _icon, props) {
            props.width = '1em';
            props.height = '1em';
        }
    }),
    viteMockServe({
        mockPath: 'mock',
        watchFiles: true
    })
];
